package com.xiaodao.beanPostProcessor;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.core.PriorityOrdered;
import org.springframework.stereotype.Component;

/**
 * 自定义
 */
//@Component
public class TestBeanPostProcessor implements BeanPostProcessor, PriorityOrdered {
	@Override
	public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {

		if(beanName.equals("indexDao")){
			System.out.println("TestBeanPostProcessor.postProcessBeforeInitialization");
		}
		return bean;
	}

	@Override
	public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
		if(beanName.equals("indexDao")){
			System.out.println("TestBeanPostProcessor.postProcessAfterInitialization");
		}
		return bean;
	}

	/**
	 * 执行的顺序 值越小越先执行
	 * @return
	 */
	@Override
	public int getOrder() {
		return 100;
	}
}
